function [data,compensation] = Data_Acquisition(handle, acqinfo)
transfer.Channel = 1;
transfer.Mode = CsMl_Translate('Default', 'TxMode');
transfer.Segment = 1;
transfer.Start = -acqinfo.TriggerHoldoff;   % Default = 0
transfer.Length = acqinfo.SegmentSize;    

ret = CsMl_Capture(handle);
CsMl_ErrorHandler(ret, 1, handle);
status = CsMl_QueryStatus(handle);
disp('Waiting for trigger signal');

motor_repeated_maxon;
tStop = now + 12/(24*60*60); % wait for 12s

while status ~= 0
    status = CsMl_QueryStatus(handle);
    if( now > tStop )
        fprintf('No trigger signal for %i seconds.\n',12);
%         status
        return;
    end
    pause(0.1);
end

disp('Signal acquired');
time_1 = now;
[ret, data, actual] = CsMl_Transfer(handle, transfer);
CsMl_ErrorHandler(ret, 1, handle);

if actual.ActualLength ~= 0
    if actual.ActualLength < length(data)  
        data(actual.ActualLength:end) = [];
    end
end

transfer.Channel = 2;
[ret, compensation, actual] = CsMl_Transfer(handle, transfer);
CsMl_ErrorHandler(ret, 1, handle);

if actual.ActualLength ~= 0
    if actual.ActualLength < length(compensation)  
        compensation(actual.ActualLength:end) = [];
    end
end

time_2 = now - time_1;
fprintf('Data transferred, cost %.1f seconds \n', time_2*24*3600);